package com.guochenglang.www.dao.impl;

import com.guochenglang.www.dao.BaseDao;
import com.guochenglang.www.pojo.Base;
import com.guochenglang.www.util.GetTable;
import com.guochenglang.www.util.connect.JdbcUtil;

import java.sql.SQLException;
import java.util.ArrayList;

/**
 * 知识库表的Dao层
 *
 * @author 郭程朗
 */
public class BaseDaoImpl implements BaseDao {
    /**
     * 表名
     */
    private static final String TABLE = GetTable.getTable(Base.class);

    public BaseDaoImpl() {
    }

    @Override
    public ArrayList<Base> baseSelect(Base base) throws SQLException, IllegalAccessException, InstantiationException, InterruptedException {
        return JdbcUtil.selectMax(TABLE, base);
    }

    @Override
    public ArrayList<Base> baseSelectByLimit(int page, int num, Base base, String order, String mode) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException {
        return JdbcUtil.selectByLimit(TABLE, page, num, base, order, mode);
    }


    @Override
    public int insertBase(Base base) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.insert(TABLE, base);
    }

    @Override
    public int updateBase(Base set, Base conditions) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.update(TABLE, set, conditions);
    }

    @Override
    public int deleteBase(Base conditions) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.delete(TABLE, conditions);
    }
}
